package com.caicai.springbootrocketmq.controller;

import com.caicai.springbootrocketmq.product.ServerTransactionProduct;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 交易
 * @author chenrui
 * @date 2024/12/9
 */
@RequestMapping("/transation")
@RestController
@Slf4j
public class TransactionController {
    private static final String transactionTopic = "TransactionTopicTest";

    @Autowired
    private ServerTransactionProduct transactionProduct;

    /**
     * 发送交易
     *
     * @param orderId
     * @return
     */
    @GetMapping("/sendTransactionMsg/{orderId}")
    public String sendTransactionMsg(@PathVariable("orderId") Integer orderId) {
        String msg = "sendTransactionMsg " + orderId;
        transactionProduct.sendTransactionMsg(transactionTopic, msg, orderId.toString());
        return "send " + msg + "ok";
    }
}
